package com.github;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * Description:
 *
 * @author zwl
 * @version 1.0
 * @date 2021/3/14 上午11:03
 */
public class Test {

    static int a = 0;

    static volatile Integer[] ins = new Integer[]{0};
    // ins
    // ins[0] ins[1]

    public static void main(String[] args) throws InterruptedException {

        //System.out.println(1 << 30);
        //System.out.println(Math.pow(2,30));
        //
        CountDownLatch latch = new CountDownLatch(1);

        for(int i = 0;i < 10;i++){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        for (int j = 0; j < 10000; j++) {
                            ins[0]++;
                        }
                    } finally {
                        latch.countDown();
                    }
                }
            }).start();
        }

        latch.await();
        System.out.println(ins[0]);


        //System.out.println(Math.pow(2,31) - 1);
        //
        //System.out.println(Integer.MAX_VALUE);
        //
        ////for(int i = 1;i <= 9;i++){
        ////    for(int j = 1;j <= i;j++){
        ////        int sum = j * i;
        ////        System.out.print(j + "*" + i + "=" + sum + "\t");
        ////    }
        ////    System.out.println("");
        ////}
        ////
        ////try(Scanner sc = new Scanner(System.in);){
        ////    int value;
        ////    LinkedList<Integer> list = new LinkedList<>();
        ////    while((value = sc.nextInt()) != -1){
        ////        if(list.size() == 0){
        ////            list.add(value);
        ////        }else{
        ////            list.push(value);
        ////        }
        ////    }
        ////    list.forEach(v ->{
        ////        System.out.print(v + "   ");
        ////    });
        ////}
        //
        ////int sum = Integer.MAX_VALUE;
        ////
        ////System.out.println(sum + 1);
        //
        //
        ////try {
        ////    System.out.println(0);
        ////    int i = 10 / 0;
        ////    System.out.println(1);
        ////}catch (Exception e){
        ////    System.out.println(2);
        ////}finally {
        ////    System.out.println(3);
        ////}
        ////System.out.println(4);
        ////
        ////int[] arr = new int[]{1,-1,0,9,5,2,9};
        ////System.out.println(new Test().getMaxWithList(arr));
        //
        ////int[][] ins = {{1,4},{2,5}};
        //
        ////String str = "1,2,4";
        //
        //try(Scanner sc = new Scanner(System.in)){
        //    String str = sc.nextLine();
        //    if(str.length() == 0){
        //        System.out.println(0);
        //    }
        //    str = str + ",#";
        //    String[] sp = str.split(",");
        //    int num = 1;
        //    for(int i = 1;i < sp.length;i++){
        //        if(!"#".equals(sp[i]) && !sp[i].equals(sp[i - 1])){
        //            num++;
        //        }
        //    }
        //    System.out.println(num);
        //}

        //String[] split = str.split(",");

        //for(int i = 0;i < )

        //System.out.println(findNumberIn2DArray(ins,2));
    }



    public static boolean findNumberIn2DArray(int[][] matrix, int target) {
        int i = 0, j= 0;
        int max_i = matrix.length,max_j = matrix[0].length;

        out: while((max_i - i) * (max_j - j) > 1){
            int k = j;
            // i , j++
            for(;j < max_j;j++){
                if(matrix[i][j] == target){
                    break out;
                }else if(matrix[i][j] > target){
                    break;
                }
            }
            max_j = j;

            int v = i;
            j = k;
            // i++, j
            for(;i < max_i;i++){
                if(matrix[i][j] == target){
                    break out;
                }else if(matrix[i][j] > target){
                    break;
                }
            }
            max_i = i;


            i = v + 1;
            j = k + 1;
        }

        if(i >= matrix.length){
            i = matrix.length - 1;
        }

        if(j >= matrix[0].length){
            j = matrix[0].length - 1;
        }

        return matrix[i][j] == target;
    }
    public int getMaxWithList(int[] arr){
        int curMax = 0, resMax = 0;
        for (int j : arr) {
            curMax = curMax + j;
            if (curMax > resMax) {
                resMax = curMax;
            } else if (curMax < 0) {
                curMax = 0;
            }
        }
        return resMax;
    }
}
